package ${packageName}.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import com.github.pagehelper.Page;
import ${packageName}.dao.${tableInfo.tableClassName}Mapper;
import ${packageName}.entity.${tableInfo.tableClassName};
import ${packageName}.entity.${tableInfo.tableClassName}Example;
import ${packageName}.service.${tableInfo.tableClassName}Service;

/**
 * ${tableInfo.tableRemark} 接口类实现类
 **/
@Service
public class ${tableInfo.tableClassName}ServiceImpl implements ${tableInfo.tableClassName}Service {

	@Resource
	private ${tableInfo.tableClassName}Mapper ${tableInfo.objectBeanName}Mapper;

	@Override
	public int deleteByExample(${tableInfo.tableClassName}Example example) {
		return ${tableInfo.objectBeanName}Mapper.deleteByExample(example);
	}
	
	@Override
	public boolean delete(List<${tableInfo.tablePkInfo.javaType}> ${tableInfo.tablePkInfo.javaName}s) {
		if(!CollectionUtils.isEmpty(${tableInfo.tablePkInfo.javaName}s)){        	
            ${tableInfo.tablePkInfo.javaName}s.forEach( x -> {
            	${tableInfo.tableClassName}Example example=new ${tableInfo.tableClassName}Example();
            	example.createCriteria().andIdEqualTo(x);
            	${tableInfo.objectBeanName}Mapper.deleteByExample(example);
            });
           return true;
        }
		return false;
	}
	@Override
	public int insert(${tableInfo.tableClassName} record) {
		return ${tableInfo.objectBeanName}Mapper.insert(record);
	}

	@Override
	public int insertSelective(${tableInfo.tableClassName} record) {
		return ${tableInfo.objectBeanName}Mapper.insert(record);
	}

	@Override
	public List<${tableInfo.tableClassName}> selectByExampleList(${tableInfo.tableClassName}Example example) {
		return ${tableInfo.objectBeanName}Mapper.selectByExampleList(example);
	}

	@Override
	public Page<${tableInfo.tableClassName}> selectByExamplePage(${tableInfo.tableClassName}Example example) {
		return ${tableInfo.objectBeanName}Mapper.selectByExamplePage(example);
	}

	@Override
	public ${tableInfo.tableClassName} selectByPrimaryKey(${tableInfo.tablePkInfo.javaType} ${tableInfo.tablePkInfo.javaName}) {
		return ${tableInfo.objectBeanName}Mapper.selectByPrimaryKey(${tableInfo.tablePkInfo.javaName});
	}


	@Override
	public int updateByPrimaryKeySelective(${tableInfo.tableClassName} record) {
		return ${tableInfo.objectBeanName}Mapper.updateByPrimaryKeySelective(record);
	}


	@Override
	public int updateByPrimaryKey(${tableInfo.tableClassName} record) {
		return ${tableInfo.objectBeanName}Mapper.updateByPrimaryKey(record);
	}

}
